package com.lyc.controller;

import com.lyc.service.ISolrService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.solr.client.solrj.SolrServerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

@Controller
@RequestMapping("/test")
public class TestController {

    @Autowired
    private ISolrService solrService;

//    @Autowired
//    private IBaseCacheService redisService;

    /**
     * 框架测试
     * @return
     */
    @RequestMapping
    public String hello(){
        return "test/hello";
    }

    /**
     * solr测试
     * @return
     * @throws IOException
     * @throws SolrServerException
     */
    @RequestMapping("/solr")
    @ResponseBody
    public String solr() throws IOException, SolrServerException {
        solrService.test();
        return "solrTest";
    }

    /**
     * shiro测试
     * @return
     * @throws IOException
     * @throws SolrServerException
     */
    @RequiresRoles("user")
    @RequestMapping("/shiro")
    @ResponseBody
    public String shiro() throws IOException, SolrServerException {
        return "shiroTest";
    }

    @RequestMapping("/error")
    public String error() throws IOException, SolrServerException {
        return "common/errorModal";
    }
}
